#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<assert.h>

void* my_memmove(void*dest, const void* src, size_t count)
{
	assert(dest&&src);
	void* tmp = dest;
	if (dest > src)
	{
		while (count--)
		{
			*((char*)tmp + count)=*((char*)src + count);

		}
	}
	else
	{
		while (count--)
		{
			*(char*)tmp  = *(char*)src;
			tmp = (char*)tmp + 1;
			src = (char*)src + 1;
		}
	}
	return dest;
}
void* my_memcpy(void* dest,void*src,size_t count)
{
	assert(dest&&src);
	void* tmp = dest;
	for (int i = 0; i < (int)count; i++)
	{
		*((char*)tmp + i)=*((char*)src + i);
	}
	return dest;
}
char * my_strstr(const char*str1, const char*str2)
{
	assert(str1&&str2);
	char* s1 = str1;
	char* s2 = str2;
	char* equals = str1;
	while (*equals)
	{
		s1 = equals;
		s2 = str2;
		while (*s1&&*s2&&(*s1 == *s2))
		{
			s1++;
			s2++;
		}
					
		if (*s2=='\0')
		{
			return equals;
		}
		equals++;
	}
	return NULL;
}
char * my_strcat(char* dest, const char* src)
{
	assert(dest&&src);
	char* tmp = dest;
	while (*tmp)
	{
		tmp++;
	}
	while (*tmp++ = *src++)
	{
		;
	}
	return dest;
}
int my_strcmp(const char* str1, const char* str2)
{
	assert(str1&&str2);
	while (*str1 == *str2)
	{
		if (*str1 == '\0')
		{
			return 0;
		}
		str2++;
		str1++;
	}
	return *str1 - *str2;

}
char* my_strcpy(char*dest, const char* src)
{
	assert(dest&&src);
	char* tmp = dest;
	while (*tmp++ = *src++)
	{
		;
	}
	return dest;
}
size_t my_strlen1(const char* str)
{
	size_t count=0;
	assert(str);
	while (*str++)
	{
		count++;
	}
	return count;
}
size_t my_strlen2(const char* str)
{
	if (*str == '\0')
	{
		return 0;
	}
	else return 1 + my_strlen2(str + 1);
}
size_t my_strlen3(const char* str)
{
	char* tail = str;
	while (*tail)
	{
		tail++;
	}
	return tail - str;
}
//int main()
//{
//	int i = 0;
//	int j = 3;
//	char arr2[20] = "abcdef";
//	char arr[] = "qqq";
//	//my_memcpy(arr2, arr, 32);
//	//my_memmove(arr + 2, arr, 16);
//	my_strcpy(arr2, arr);
//	int tmp=strcmp("aa", "baa");
//	printf("%d\n", tmp);
//	//for (int i = 0; i < 20; i++)
//	//{
//	//	printf("%d ", arr2[i]);
//	//}
//	///*char* tmp=my_strstr("i am a beauty yes", "beauty");
//	printf("%s\n", arr2);
//
//	return 0;
//}
int main()
{
	char arr[] = "aqetrthgf";
	int tmp=my_strlen3(arr);
	printf("%d\n", tmp);
	return 0;
}